import React, { Component } from 'react';

class Index extends Component {
  state = {
    token: localStorage.getItem('token')
  }
  // 退出登录
  quit() {
    // 清除本地存储
    localStorage.removeItem('token')
    // 返回登录页面
    this.props.history.push('/login')
  }
  render() {
    const { token } = this.state
    return (
      <div>
        欢迎：{ token } <button onClick={ () => this.quit() }>退出登录</button>
      </div>
    );
  }
}

export default Index;
